home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / prodpack.zip / DB4PPSRC.EXE / _STRINBO.PRG < prev    next >
Text File  |  1993-05-04  |  2KB  |  85 lines

  1. FUNCTION _StrInBox
  2. PARAMETERS pn_row, pn_col, pc_prompt, pc_str, pn_maxlen, pn_scroll
  3. *---------------------------------------------------------------------
  4. * NAME
  5. *   _StrInBox - Get a string in a box
  6. *
  7. * DESCRIPTION
  8. *     This routine implements the fill-in popup to get a string
  9. *     from the user.    The box dimensions are determined on the
  10. *     fly depending upon the prompt length and the scroll_len.
  11. *     The height of the box is assumed to be 3.
  12. *
  13. *     If an error is encountered during processing, that error is displayed
  14. *     with a beep and we return -1 with the original string value
  15. *     remaining unchanged.  If the user hits ESCAPE key then also -1
  16. *     is returned (without changing the original string value) and the
  17. *     caller should take appropriate action (may be no action).
  18. *
  19. *
  20. * SYNOPSIS
  21. *
  22. * PARAMETERS
  23. *   pn_row      = Top row position
  24. *   pn_col      = Left column position
  25. *   pc_prompt   = Prompt inside of the box
  26. *   pc_str      = Starting value
  27. *   pn_maxlen   = Maximum length of the string
  28. *   pn_scroll   = Scroll length for the input string
  29. *
  30. * LIMITATIONS
  31. *
  32. * DEPENDENCIES
  33. *
  34. *---------------------------------------------------------------------
  35.   PRIVATE ll_deli, lc_str, lc_pict, ll_confirm, ln_rtn, ln_inboxw, ;
  36.           ln_getcol, lc_window
  37.  
  38.   ll_deli = SET("DELIMITER") = "ON"
  39.   SET DELIMITER OFF
  40.   ll_confirm = SET("CONFIRM") = "ON"
  41.   SET CONFIRM ON
  42.  
  43.   lc_window = WINDOW()
  44.  
  45.   ln_inboxw = LEN( pc_prompt ) + 3 + pn_scroll
  46.   lc_str = pc_str + SPACE( pn_maxlen - LEN( pc_str ) )
  47.   DEFINE WINDOW StrInBox FROM pn_row, pn_col ;
  48.                          TO pn_row+2, pn_col+ln_inboxw+1 DOUBLE
  49.   ACTIVATE WINDOW StrInBox
  50.   @ 0,0 SAY [ ] + pc_prompt + [  ]
  51.  
  52.   lc_pict = "@S" + LTRIM( STR( pn_scroll, 3 ) )
  53.   ln_getcol = ln_inboxw - pn_scroll
  54.   ln_rtn = 0
  55.  
  56.   DO WHILE .T.
  57.     @ 0, ln_getcol GET lc_str PICTURE ( lc_pict )
  58.     DO _Read_It
  59.     ln_lastkey = LASTKEY()
  60.     IF ln_lastkey = 27
  61.       ln_rtn = -1
  62.     ELSE
  63.       pc_str = lc_str
  64.     ENDIF
  65.  
  66.     EXIT
  67.   ENDDO
  68.  
  69.   IF ll_deli
  70.     SET DELIMITER ON
  71.   ENDIF
  72.   IF .NOT. ll_confirm
  73.     SET CONFIRM OFF
  74.   ENDIF
  75.   SET CURSOR ON
  76.  
  77.   RELEASE WINDOW StrInBox
  78.   IF .NOT. ISBLANK( lc_window )
  79.     ACTIVATE WINDOW &lc_window
  80.   ENDIF
  81.  
  82. RETURN( ln_rtn )
  83. *-- EOF:  _StrInBox( pn_row, pn_col, pc_prompt, pc_str, pn_max, pn_scroll )
  84.  
  85.